<?php

namespace MyApp\Hook;

use RedBean_Facade as R;

class Friendship
{
    public static function afterCreate($friendship)
    {
        $app = \Slim\Slim::getInstance();
        if ($app->friend) {
            $coins = $app->friend->coins;
            $app->friend->coins = is_null($coins) ? 10000 : $coins + 10000;
            R::store($app->friend);
        }
    }
}